﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ECommerce.Model.Productos
{
    public class Package : ECommerce.Model.Objeto
    {
        private double cantidadXBulto;
        public double CantidadXBulto
        {
            get { return cantidadXBulto; }
            set { cantidadXBulto = value; }
        }
        public override void Load(int ident)
        {
            base.Load(ident);
            this.Load(ECommerce.DAO.Cache.Productos.Package.GetPackageById(ident));
            if (this.Id == 0)
            {
                this.Load(ECommerce.DAO.SQL.Productos.Package.GetPackageById(ident));
                ECommerce.DAO.Cache.Productos.Package.SetPackage(this);
            }
        }
        public void Load(ECommerce.Model.Productos.Package Package)
        {
            if (Package != null)
            {
                this.CantidadXBulto = Package.CantidadXBulto;
            }
        }
        public override void Load(System.Data.DataRow dr)
        {
            base.Load(dr);
            ECommerce.Factory.Productos.Package.Load(this, dr);
            ECommerce.DAO.Cache.Productos.Package.SetPackage(this);
        }
        public override void Save()
        {
            base.Save();
            this.Id = ECommerce.DAO.SQL.Productos.Package.SetPackage(this);
            this.Id = ECommerce.DAO.Cache.Productos.Package.SetPackage(this);
            ECommerce.DAO.Cache.Productos.Package.DelPackages();
        }
        public override string ToString()
        {
            return base.ToString() + "(" + this.CantidadXBulto + ")";
        }
    }
}
